﻿/// <reference path="backbone-min.js" />
/// <reference path="jquery-1.8.3.min.js" />
/// <reference path="underscore-min.js" />
/// <reference path="../exclude/sp.js" />
/// <reference path="app.js" />
'use strict';

var Bk = Backbone;

var AppRouter = Bk.Router.extend({
    routes: {
        'ezEdit'           :       'ezEdit',
        ''                 :       'home',
        'viewedLists'      :       'viewedLists',
        'ChartTypes'       :       'chartTypes',
        'Configuration'    :       'configuration'
    },

    ezEdit: function (actions)
    {
        App.ChartConfiguration.set({ configurationInfo: 'Configuring Chart App...', back: '#', showBack: true });
        $('#content').hide(500, null, function () { $('#ezEdit').show(500); });
        
        App.EzEditView.render();
    },

    viewedLists: function (actions)
    {
        App.ChartConfiguration.set({ configurationInfo: 'Configuring View Lists setting...', back: 'ezEdit', showBack: true });
        if (App.ViewedListsView) {
            App.ViewedListsView.render();
        }
        else {
            App.ErrorMessage = null;
            App.ErrorInEzEditView.render();
        }
       
    },

    home:function(actions)
    {
        App.ChartConfiguration.set({ configurationInfo: '', back: '#', showBack: false });
        $('#ezEdit').hide(500, null, function () { $('#content').show(500); });

        App.MainView.render();

        //createChart();
    },

    chartTypes:function(action)
    {
        App.ChartConfiguration.set({ configurationInfo: 'Configuring Chart Types...', back: 'ezEdit', showBack: true });
        if (App.ChartTypesView &&
            App.ChartTypesView.render) {
            App.ChartTypesView.render();
        }
        else {
            App.ErrorInEzEditView.render();
        }
    },

    configuration: function () {
        App.ChartConfiguration.set({ configurationInfo: 'Configuring Chart App...', back: 'ezEdit', showBack: true });
        if (App.ConfigurationView &&
            App.ConfigurationView.render) {
            App.ConfigurationView.render();
        }
        else {
            App.ErrorInEzEditView.render();
        }
    },

    initialize: function () {
        Bk.history.start();
    }
});




